package com.jf.controller;

import com.alibaba.fastjson.JSON;
import com.jf.service.TokenService;
import com.jf.service.impl.TokenServiceImpl;
import com.jf.util.ResultJson;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/logout")
public class LogoutServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        TokenService tokenService = new TokenServiceImpl();
        String token = request.getHeader("token");
        tokenService.logout(token);
        response.getWriter().println(JSON.toJSON(ResultJson.success()));
    }
}
